/**
 *  Copyright (C) 2010  Thomas Volk
 *
 *  This program is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU Lesser General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 */
package com.googlecode.bookmarks.web;

import com.googlecode.bookmarks.web.pages.LoginPage;
import org.apache.wicket.authentication.AuthenticatedWebApplication;
import org.apache.wicket.authentication.AuthenticatedWebSession;
import org.apache.wicket.markup.html.WebPage;
import org.apache.wicket.spring.injection.annot.SpringComponentInjector;

import com.googlecode.bookmarks.core.service.DatabaseInitialisationService;
import com.googlecode.bookmarks.web.pages.HomePage;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.BeanFactoryAware;


/**
 *
 * @author tom
 */
public class BookmarksApplication extends AuthenticatedWebApplication  {
	private DatabaseInitialisationService databaseInitialisationService;

    public DatabaseInitialisationService getDatabaseInitialisationService() {
		return databaseInitialisationService;
	}
	
	public void setDatabaseInitialisationService(
			DatabaseInitialisationService databaseInitialisationService) {
		this.databaseInitialisationService = databaseInitialisationService;
	}

	@Override
    public void init() {
        super.init();
        initSpringComponentInjector();
    }

    @Override
    protected Class<? extends AuthenticatedWebSession> getWebSessionClass() {
        return BookmarksSession.class;
    }

    @Override
    protected Class<? extends WebPage> getSignInPageClass() {
        return LoginPage.class;
    }

    protected void initSpringComponentInjector() {
        addComponentInstantiationListener(new SpringComponentInjector(this));
        getDatabaseInitialisationService().initialize();
    }

    @Override
    public Class<HomePage> getHomePage() {
        return HomePage.class;
    }
}
